package cn.piesat.dao;

import cn.piesat.dto.PiesatRoleInfoDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 角色信息持久层
 *
 * @author xhl
 */
public interface PiesatRoleInfoDAO extends JpaRepository<PiesatRoleInfoDTO,String>, JpaSpecificationExecutor<PiesatRoleInfoDTO> {
    PiesatRoleInfoDTO findByName(String name);

    PiesatRoleInfoDTO findByMark(String mark);

    @Query(nativeQuery = true,value = "select c.NAME  from piesat_role_user_relation m inner join piesat_user_userinfo r on m.user_ID = r.ID " +
            " INNER JOIN piesat_role_info c on m.ROLE_ID = c.id " +
            " where r.userNAME = :userName and r.LOCK_STATE =0  ")
    List<String> findRoleNmaeListByUserName(String userName);
}
